#!/usr/bin/php
<?PHP
$xml = '<xml><ToUserName><![CDATA[gh_6fa6cc554c31]]></ToUserName>
<FromUserName><![CDATA[olPyqxNvWBYa5a4WaUo0-hJH65_c]]></FromUserName>
<CreateTime>1479288672</CreateTime>
<MsgType><![CDATA[event]]></MsgType>
<Event><![CDATA[LOCATION]]></Event>
<Latitude>22.537746</Latitude>
<Longitude>114.008957</Longitude>
<Precision>40.000000</Precision>
</xml>';

$sx = simplexml_load_string($xml);

echo $sx->ToUserName, PHP_EOL;
echo $sx->FromUserName, PHP_EOL;
echo $sx->CreateTime, PHP_EOL;

$name = $sx->ToUserName->getName();
$val =  $sx->ToUserName->__toString();

echo "name = ", $name, ", val = ", $val, ", type = ", getType($val), PHP_EOL;


echo "============================", PHP_EOL;


foreach ($sx as $key => $val) {
    echo $key, '=> ', $val, ", type = ", getType($val), PHP_EOL;
}

